<?php
/**
 * 后台登陆
 */
namespace app\admin\controller;
use think\Controller;
use think\Loader;
use think\Request;
class Login extends Controller
{
    // 登陆
    public function login(){
        $requset = Request::instance();
        if(!$requset->isPost()){
            return $this->fetch();
        }else{
            $admin_username = $requset->post('admin_username');
            $admin_password = $requset->post('admin_password');
            $admin = Loader::model('admin');
            $tools = Loader::model('tools');
            $res = $admin -> login($admin_username,md5($admin_password));
            // $res = $admin -> addlogin($admin_username,$admin_password,md5($admin_password));

            // dump ($res);
            echo $res;
        }
    }

    // 退出登录
    public function loginout(){
        $admin = Loader::model('admin');
        $out = $admin->loginout();
        if($out  == "1"){
            $this->error("退出失败");
        }else{
            $this->redirect('admin/login/login');
        }
    }
}